package com.ruoyi.pims.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.pims.mapper.SalesOrderDetailsMapper;
import com.ruoyi.pims.domain.SalesOrderDetails;
import com.ruoyi.pims.service.ISalesOrderDetailsService;
import com.ruoyi.common.core.text.Convert;

/**
 * 销售订单明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-17
 */
@Service
public class SalesOrderDetailsServiceImpl implements ISalesOrderDetailsService 
{
    @Autowired
    private SalesOrderDetailsMapper salesOrderDetailsMapper;

    /**
     * 查询销售订单明细
     * 
     * @param itemId 销售订单明细主键
     * @return 销售订单明细
     */
    @Override
    public SalesOrderDetails selectSalesOrderDetailsByItemId(Long itemId)
    {
        return salesOrderDetailsMapper.selectSalesOrderDetailsByItemId(itemId);
    }

    /**
     * 查询销售订单明细列表
     * 
     * @param salesOrderDetails 销售订单明细
     * @return 销售订单明细
     */
    @Override
    public List<SalesOrderDetails> selectSalesOrderDetailsList(SalesOrderDetails salesOrderDetails)
    {
        return salesOrderDetailsMapper.selectSalesOrderDetailsList(salesOrderDetails);
    }

    /**
     * 新增销售订单明细
     * 
     * @param salesOrderDetails 销售订单明细
     * @return 结果
     */
    @Override
    public int insertSalesOrderDetails(SalesOrderDetails salesOrderDetails)
    {
        salesOrderDetails.setCreateTime(DateUtils.getNowDate());
        return salesOrderDetailsMapper.insertSalesOrderDetails(salesOrderDetails);
    }

    /**
     * 修改销售订单明细
     * 
     * @param salesOrderDetails 销售订单明细
     * @return 结果
     */
    @Override
    public int updateSalesOrderDetails(SalesOrderDetails salesOrderDetails)
    {
        salesOrderDetails.setUpdateTime(DateUtils.getNowDate());
        return salesOrderDetailsMapper.updateSalesOrderDetails(salesOrderDetails);
    }

    /**
     * 批量删除销售订单明细
     * 
     * @param itemIds 需要删除的销售订单明细主键
     * @return 结果
     */
    @Override
    public int deleteSalesOrderDetailsByItemIds(String itemIds)
    {
        return salesOrderDetailsMapper.deleteSalesOrderDetailsByItemIds(Convert.toStrArray(itemIds));
    }

    /**
     * 删除销售订单明细信息
     * 
     * @param itemId 销售订单明细主键
     * @return 结果
     */
    @Override
    public int deleteSalesOrderDetailsByItemId(Long itemId)
    {
        return salesOrderDetailsMapper.deleteSalesOrderDetailsByItemId(itemId);
    }
}
